#include "LinkQueue.h"
#include "LinkStack.h"
#include <stdio.h>
#define true 1
#define false 0
typedef struct Queue
{
    LinkStack stack1;
    LinkStack stack2;
}Queue;

void InitQueue(Queue *qp)
{
    InitLinkstack(&qp->stack1);
    InitLinkstack(&qp->stack2);
}
void StackQueuePush(Queue *qp,ElementType element)
{
    while(IsEmpty(&qp->stack2)==false)
    {
        Push(&qp->stack1,*Pop(&qp->stack2));
    }
    Push(&qp->stack1,element);
}

ElementType *StackQueuePop(Queue *qp)
{
    if(IsEmpty(&qp->stack2)==true)
    {
        while(IsEmpty(&qp->stack1)==false)
        {
            Push(&qp->stack2,*Pop(&qp->stack1));
        }
    }
    return Pop(&qp->stack2);
}
int StackQueueIsEmpty(Queue *qp)
{
    if(qp->stack1.stack.len==0&&qp->stack2.stack.len==0)
        return true;
    else
        return false;
}


void main()
{
    Queue qp;
    InitQueue(&qp);
    for(int i=0;i<10;i++)
    {
        StackQueuePush(&qp,i+1);
    }
    while(StackQueueIsEmpty(&qp)==false)
    {
        printf("%d ",*StackQueuePop(&qp));
    }
    printf("\n");
}